<template>
    <div class="main">
        <!--<x-header title="隐患措施"></x-header>-->

        <div class="detailmsg">
            {{showmodel}}
        </div>
        <div class="btns">
            <button @click="cancelmsg">取消</button>
            <button @click="savemsg"
                    class="green">保存</button>
        </div>
        <myMenu></myMenu>
    </div>

</template>

<script>
import { XHeader, Tabbar, TabbarItem, Group, Cell, Search } from 'vux'
import myMenu from '@/commonComponents/menu'
export default {
    name: 'App',
    data () {
        return {
            showmodel: '',
            userId: '',
            tokenId: '',
            projectId: '',
            userInfo: ''
        }
    },
    components: {
        Tabbar,
        TabbarItem,
        Group,
        Cell,
        XHeader,
        Search,
        myMenu
    },
    created () {
        this.userInfo = JSON.parse(localStorage.userInfo)
        this.userId = this.userInfo.userid
        this.tokenId = this.userInfo.tokenId
        this.projectId = this.userInfo.deptid
        this.selectmanage()
    },
    methods: {
        selectmanage () { // 获取隐患类别
            let id
            if (this.$route.query.id) {
                if (this.$store.state.hiddenlist1[this.$route.query.id].standardId) {
                    id = this.$store.state.hiddenlist1[this.$route.query.id].standardId
                }
            } else {
                if (this.$store.state.hiddenlist.standardId) {
                    id = this.$store.state.hiddenlist.standardId
                }
            }
            let param = {
                'allowPaging': true,
                'business': 'GetFetchHiddenDangerStandardDetail',
                'data': id,
                'pageIndex': 0,
                'pageSize': 0,
                'tokenId': this.tokenId,
                'userId': this.userId
            }
            this.$axiosAjax.getConfigJson(
                param
            ).then(
                (res) => {
                    if (res.data.code == 0) {
                        this.showmodel = res.data.data.DeptDetail
                    }
                }
            )
        },
        cancelmsg () {
            this.$router.go(-2)
        },
        savemsg () {
            localStorage.hiddenmanage = this.showmodel
            if (this.$route.query.id) {
                this.$store.state.hiddenlist1[this.$route.query.id] = Object.assign({}, this.$store.state.hiddenlist1[this.$route.query.id], {
                    'measure': this.showmodel
                })
            } else {
                this.$store.state.hiddenlist = Object.assign({}, this.$store.state.hiddenlist, {
                    'measure': this.showmodel
                })
            }
            this.$router.go(-2)
        }
    }

}

</script>

<style scoped lang="less">
.selectName {
    width: 100%;
    height: 40px;
    display: flex;
}
.detailmsg {
    width: 100%;
    padding: 20px;
}
</style>
